{include file="index/header" /}
<body>
	<div class="panel admin-panel">
		<form method="post" action="" id="listform">
			<div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
			<div class="padding border-bottom">
				<ul class="search" style="padding-left:10px;">
					<li> <a class="button border-main icon-plus-square-o" href="{:url('type/typeedit')}"> 添加内容</a> </li>
					<li>搜索：</li>
					<li>
						<select name="nav_id" class="input" style="width:200px; line-height:17px;" onchange="changesearch()">
							<option value="">请选择课程导航</option>
							{foreach name='nav_data' item='nav'}
							<option value="{$nav.nav_id}" {if $nav.nav_id eq $param.nav_id}selected=""{/if}>{$nav.nav_name}</option>
							{/foreach}
						</select>
					</li>
					<li>
						<input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" value="{$param.keywords}" />
						<a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a>
					</li>
				</ul>
			</div>
			<table class="table table-hover text-center">
				<tr>
					<th>ID</th>
					<th>排序</th>
					<th>名称</th>
					<th>专业</th>
					<th>操作</th>
				</tr>
				{foreach name='data' item='v'}
				<tr>
					<td><input type="checkbox" name="type_id[]" value="{$v.type_id}" />{$v.type_id}</td>
					<td><input type="text" name="type_sort[{$v.type_id}]" value="{$v.type_sort}" style="width:50px; text-align:center; border:1px solid #ddd; padding:7px 0;"></td>
					<td>{$v.type_name}</td>
					<td>{$v.nav_name}</td>
					<td><div class="button-group"><a class="button border-main" href="{:url('type/typeedit',['type_id' => $v['type_id']])}"><span class="icon-edit"></span> 修改</a><a class="button border-red" href="{:url('type/typedelete',['type_id' => $v['type_id']])}" onclick="if(confirm('确定删除?')==false)return false;"><span class="icon-trash-o"></span> 删除</a></div></td>
				</tr>
				{/foreach}
				<tr>
					<td><input type="checkbox" id="checkall"/>
					全选 </td>
					<td colspan="7" style="text-align:left;padding-left:20px;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> <a href="javascript:void(0)" style="padding:5px 15px; margin:0 10px;" class="button border-blue icon-edit" onclick="sorts()"> 排序</a>
					</td>
				</tr>
				<tr>
					<td colspan="5">{$data->render()}</td>
				</tr>
			</table>
			<input type="hidden" name="status" value="">
		</form>
	</div>
	<script>
	//搜索
	function changesearch(){  
		$('input[name=status]').val('select');
		$("#listform").submit();
	}
	//全选
	$("#checkall").click(function(){ 
		$("input[name='type_id[]']").each(function(){
			if (this.checked) {
				this.checked = false;
			}
			else {
				this.checked = true;
			}
		});
	});

	//批量删除
	function DelSelect(){
		var Checkbox=false;
		$("input[name='type_id[]']").each(function(){
			if (this.checked==true) {   
				Checkbox=true;  
			}
		});
		if (Checkbox){
			var t=confirm("您确认要删除选中的内容吗？");
			if (t==false) return false;   
			$('input[name=status]').val('del');
			$("#listform").submit();    
		}
		else{
			alert("请选择您要删除的内容!");
			return false;
		}
	}

	//批量排序
	function sorts(){
		var Checkbox=false;
		$("input[name='type_id[]']").each(function(){
			if (this.checked==true) {   
				Checkbox=true;  
			}
		});
		if (Checkbox){  
			$('input[name=status]').val('sort');
			$("#listform").submit();    
		}
		else{
			alert("请选择要操作的内容!");
			return false;
		}
	}

	//批量移动
	function changecate(o){
		var Checkbox=false;
		$("input[name='type_id[]']").each(function(){
			if (this.checked==true) {   
				Checkbox=true;  
			}
		});
		if (Checkbox){    
			$('input[name=status]').val('move');
			$("#listform").submit();    
		}
		else{
			alert("请选择要操作的内容!");
			
			return false;
		}
	}
</script>
</body></html>